import { Navigate } from "react-router-dom"
import React, { lazy } from 'react';
import Loading from "@/components/Loading";



const LazyImportComponent = (props) => {
    return (
        <React.Suspense fallback={<Loading />}>
            <props.lazyChildren />
        </React.Suspense>
    );
};

const routes = [
    {
        path: "/msg",
        element: <LazyImportComponent lazyChildren={lazy(() => import("@/views/messages/Messages"))} />
    },
    {
        path: "/add_med",
        element: <LazyImportComponent lazyChildren={lazy(() => import("@/views/add_medication/AddMedication"))} />
    },
    {
        path: "/medication",
        element: <LazyImportComponent lazyChildren={lazy(() => import("@/views/medication/Medication"))} />
    },
    {
        path: "/add_mem",
        element: <LazyImportComponent lazyChildren={lazy(() => import("@/views/add_memoire/AddMemoire"))} />
    },
    {
        path: "/memo",
        element: <LazyImportComponent lazyChildren={lazy(() => import("@/views/memoire/Memoire"))} />
    },
    {
        path: "/archives",
        element: <LazyImportComponent lazyChildren={lazy(() => import("@/views/hlth_archives/HlthArchives"))} />
    },
    {
        path: "/main",
        element: <LazyImportComponent lazyChildren={lazy(() => import("@/views/main/Main"))} />
    },
    {
        path: "/msg",
        element: <LazyImportComponent lazyChildren={lazy(() => import("@/views/activity_msg/ActivityMsg"))} />
    },
    {
        path: "/set",
        element: <LazyImportComponent lazyChildren={lazy(() => import("@/views/setting/Setting"))} />
    },
    {
        path: "/activity",
        element: <LazyImportComponent lazyChildren={lazy(() => import("@/views/activity/Activity"))} />
    },
    {
        path: "/rank",
        element: <LazyImportComponent lazyChildren={lazy(() => import("@/views/rank/Rank"))} />
    },
    {
        path: "/detail",
        element: <LazyImportComponent lazyChildren={lazy(() => import("@/views/activity_detail/ActivityDetail"))} />
    },
    {
        path: "/*",
        element: <Navigate to="/main" />
    }
];

export default routes;